package com.foodie.service;

import com.foodie.dao.DB;
import com.foodie.entity.Menu;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class selectService {
    public List<Menu> getselect(Integer id) {

        List<Map<String, Object>> result = DB.executeQuery("SELECT * from t_menu where ID=?",id);
        List<Menu> userList = new ArrayList<>();
        if (result != null) {
            for (int i = 0; i < result.size(); i++) {
                Map<String, Object> data = result.get(i);
                Menu image = new Menu();
                image.setID((Integer) data.get("ID"));
                image.setMENU_NAME((String) data.get("MENU_NAME"));
                image.setMENU_INTRODUCE((String) data.get("MENU_INTRODUCE"));
                image.setIMAGE((String) data.get("IMAGE"));
                image.setMENU_TIME((String) data.get("MENU_TIME"));
                image.setVIEW((Integer) data.get("VIEW"));
                image.setPRICE((Integer) data.get("PRICE"));
                image.setCREATE_TIME((String) data.get("CREATE_TIME"));
                image.setUPDATE_TIME((String) data.get("UPDATE_TIME"));
                userList.add(image);
            }
        }

        return userList;
    }
}
